<?php

namespace app\models\Child;

use Yii;

/**
 * This is the model class for table "token".
 *
 * @property integer $id
 * @property string $access_token
 * @property integer $create_time
 */
class Token extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'token';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['create_time'], 'integer'],
            [['access_token'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'access_token' => 'Access Token',
            'create_time' => 'Create Time',
        ];
    }
    
    public function setToken($access_token,$create_time)
    {
        $tokens = $this->find()
                    ->where(['id' => 1])
                    ->one();
            $tokens->access_token = $access_token;
            $tokens->create_time = $create_time;
            return $tokens->save();
    }
    
    public function getToken()
    {
        $list = $this->find()
                    ->where(['id' => 1])
                    ->one();
        return $list;
    }
}
